package Kuaishou;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.apache.commons.collections.CollectionUtils;

import com.google.common.collect.Sets;

/**
 * @author leiwenkang <leiwenkang@kuaishou.com>
 * Created on 2021-03-17
 */
public class Test29 {
    public static void main(String[] args) {

        List<Integer> listA = new ArrayList<>();
        listA.add(1);
        listA.add(2);
        listA.add(3);
        listA.add(4);
        Set<Integer> listB = Sets.newHashSet();
        listB.add(1);
//        listB.add(5);
//        listB.add(6);
        System.out.println("集合A:"+listA);
        System.out.println("集合B:"+listB);
        System.out.println("------------------------");
        //并集
        Collection<Integer> union = CollectionUtils.union(listA, listB);
        System.out.println("并集："+union);
        //交集
        Collection<Integer> intersection = CollectionUtils.intersection(listA, listB);
        System.out.println("交集："+intersection);
        //交集的补集
        Collection<Integer> disjunction = CollectionUtils.disjunction(listA, listB);
        System.out.println("交集的补集   ："+disjunction);
        //差集(集合相减)
        Collection<Integer> subtract = CollectionUtils.subtract(listA, listB);
        System.out.println("差集(集合相减)   ："+subtract);
        //是否包含
        boolean containsAll = listA.containsAll(listB);
        System.out.println("是否包含："+ containsAll);
    }

}
